var t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
    return typeof t;
} : function(t) {
    return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
};

!function(n) {
    if ("function" == typeof bootstrap) bootstrap("promise", n); else if ("object" === ("undefined" == typeof exports ? "undefined" : t(exports)) && "object" === ("undefined" == typeof module ? "undefined" : t(module))) module.exports = n(); else if ("function" == typeof define && define.amd) define(n); else if ("undefined" != typeof ses) {
        if (!ses.ok()) return;
        ses.makeQ = n;
    } else {
        if ("undefined" == typeof window && "undefined" == typeof self) throw new Error("This environment was not anticipated by Q. Please file a bug.");
        var e = "undefined" != typeof window ? window : self, r = e.Q;
        e.Q = n(), e.Q.noConflict = function() {
            return e.Q = r, this;
        };
    }
}(function() {
    function n(t) {
        return function() {
            return I.apply(t, arguments);
        };
    }
    function e(t) {
        return t === Object(t);
    }
    function r(t) {
        return "[object StopIteration]" === L(t) || t instanceof N;
    }
    function o(n, e) {
        if (Q && e.stack && "object" === (void 0 === n ? "undefined" : t(n)) && null !== n && n.stack) {
            for (var r = [], o = e; o; o = o.source) o.stack && (!n.__minimumStackCounter__ || n.__minimumStackCounter__ > o.stackCounter) && (V(n, "__minimumStackCounter__", {
                value: o.stackCounter,
                configurable: !0
            }), r.unshift(o.stack));
            r.unshift(n.stack);
            var u = i(r.join("\n" + q + "\n"));
            V(n, "stack", {
                value: u,
                configurable: !0
            });
        }
    }
    function i(t) {
        for (var n = t.split("\n"), e = [], r = 0; r < n.length; ++r) {
            var o = n[r];
            f(o) || u(o) || !o || e.push(o);
        }
        return e.join("\n");
    }
    function u(t) {
        return -1 !== t.indexOf("(module.js:") || -1 !== t.indexOf("(node.js:");
    }
    function c(t) {
        var n = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);
        if (n) return [ n[1], Number(n[2]) ];
        var e = /at ([^ ]+):(\d+):(?:\d+)$/.exec(t);
        if (e) return [ e[1], Number(e[2]) ];
        var r = /.*@(.+):(\d+)$/.exec(t);
        return r ? [ r[1], Number(r[2]) ] : void 0;
    }
    function f(t) {
        var n = c(t);
        if (!n) return !1;
        var e = n[0], r = n[1];
        return e === _ && r >= P && r <= Y;
    }
    function s() {
        if (Q) try {
            throw new Error();
        } catch (e) {
            var t = e.stack.split("\n"), n = c(t[0].indexOf("@") > 0 ? t[1] : t[2]);
            if (!n) return;
            return _ = n[0], n[1];
        }
    }
    function p(t) {
        return t instanceof h ? t : k(t) ? T(t) : x(t);
    }
    function a(t, n) {
        function e(t) {
            r = t, p.longStackSupport && Q && (c.source = t), F(o, function(n, e) {
                p.nextTick(function() {
                    t.promiseDispatch.apply(t, e);
                });
            }, void 0), o = void 0, i = void 0;
        }
        var r, o = [], i = [], u = $(a.prototype), c = $(h.prototype);
        if (c.promiseDispatch = function(t, n, e) {
            var u = U(arguments);
            o ? (o.push(u), "when" === n && e[1] && i.push(e[1])) : p.nextTick(function() {
                r.promiseDispatch.apply(r, u);
            });
        }, c.valueOf = function() {
            if (o) return c;
            var t = v(r);
            return m(t) && (r = t), t;
        }, c.inspect = function() {
            return r ? r.inspect() : {
                state: "pending"
            };
        }, p.longStackSupport && Q) try {
            throw new Error();
        } catch (t) {
            c.stack = t.stack.substring(t.stack.indexOf("\n") + 1), c.stackCounter = z++;
        }
        return u.promise = c, u.resolve = function(t) {
            r || e(p(t));
        }, u.fulfill = function(t) {
            r || e(x(t));
        }, u.reject = function(t) {
            r || e(g(t));
        }, u.notify = function(t) {
            r || F(i, function(n, e) {
                p.nextTick(function() {
                    e(t);
                });
            }, void 0);
        }, u;
    }
    function l(t) {
        if ("function" != typeof t) throw new TypeError("resolver must be a function.");
        var n = a();
        try {
            t(n.resolve, n.reject, n.notify);
        } catch (t) {
            n.reject(t);
        }
        return n.promise;
    }
    function d(t) {
        return l(function(n, e) {
            for (var r = 0, o = t.length; r < o; r++) p(t[r]).then(n, e);
        });
    }
    function h(t, n, e) {
        void 0 === n && (n = function(t) {
            return g(new Error("Promise does not support operation: " + t));
        }), void 0 === e && (e = function() {
            return {
                state: "unknown"
            };
        });
        var r = $(h.prototype);
        if (r.promiseDispatch = function(e, o, i) {
            var u;
            try {
                u = t[o] ? t[o].apply(r, i) : n.call(r, o, i);
            } catch (t) {
                u = g(t);
            }
            e && e(u);
        }, r.inspect = e, e) {
            var o = e();
            "rejected" === o.state && (r.exception = o.reason), r.valueOf = function() {
                var t = e();
                return "pending" === t.state || "rejected" === t.state ? r : t.value;
            };
        }
        return r;
    }
    function y(t, n, e, r) {
        return p(t).then(n, e, r);
    }
    function v(t) {
        if (m(t)) {
            var n = t.inspect();
            if ("fulfilled" === n.state) return n.value;
        }
        return t;
    }
    function m(t) {
        return t instanceof h;
    }
    function k(t) {
        return e(t) && "function" == typeof t.then;
    }
    function w() {
        J.length = 0, K.length = 0, X || (X = !0);
    }
    function j(n, e) {
        X && ("object" === ("undefined" == typeof process ? "undefined" : t(process)) && "function" == typeof process.emit && p.nextTick.runAfter(function() {
            -1 !== M(K, n) && (process.emit("unhandledRejection", e, n), W.push(n));
        }), K.push(n), e && void 0 !== e.stack ? J.push(e.stack) : J.push("(no stack) " + e));
    }
    function b(n) {
        if (X) {
            var e = M(K, n);
            -1 !== e && ("object" === ("undefined" == typeof process ? "undefined" : t(process)) && "function" == typeof process.emit && p.nextTick.runAfter(function() {
                var t = M(W, n);
                -1 !== t && (process.emit("rejectionHandled", J[e], n), W.splice(t, 1));
            }), K.splice(e, 1), J.splice(e, 1));
        }
    }
    function g(t) {
        var n = h({
            when: function(n) {
                return n && b(this), n ? n(t) : this;
            }
        }, function() {
            return this;
        }, function() {
            return {
                state: "rejected",
                reason: t
            };
        });
        return j(n, t), n;
    }
    function x(t) {
        return h({
            when: function() {
                return t;
            },
            get: function(n) {
                return t[n];
            },
            set: function(n, e) {
                t[n] = e;
            },
            delete: function(n) {
                delete t[n];
            },
            post: function(n, e) {
                return null === n || void 0 === n ? t.apply(void 0, e) : t[n].apply(t, e);
            },
            apply: function(n, e) {
                return t.apply(n, e);
            },
            keys: function() {
                return H(t);
            }
        }, void 0, function() {
            return {
                state: "fulfilled",
                value: t
            };
        });
    }
    function T(t) {
        var n = a();
        return p.nextTick(function() {
            try {
                t.then(n.resolve, n.reject, n.notify);
            } catch (t) {
                n.reject(t);
            }
        }), n.promise;
    }
    function R(t, n, e) {
        return p(t).spread(n, e);
    }
    function S(t, n, e) {
        return p(t).dispatch(n, e);
    }
    function E(t) {
        return y(t, function(t) {
            var n = 0, e = a();
            return F(t, function(r, o, i) {
                var u;
                m(o) && "fulfilled" === (u = o.inspect()).state ? t[i] = u.value : (++n, y(o, function(r) {
                    t[i] = r, 0 == --n && e.resolve(t);
                }, e.reject, function(t) {
                    e.notify({
                        index: i,
                        value: t
                    });
                }));
            }, void 0), 0 === n && e.resolve(t), e.promise;
        });
    }
    function O(t) {
        if (0 === t.length) return p.resolve();
        var n = p.defer(), e = 0;
        return F(t, function(r, o, i) {
            var u = t[i];
            e++, y(u, function(t) {
                n.resolve(t);
            }, function(t) {
                0 == --e && (t.message = "Q can't get fulfillment value from any promise, all promises were rejected. Last error message: " + t.message, 
                n.reject(t));
            }, function(t) {
                n.notify({
                    index: i,
                    value: t
                });
            });
        }, void 0), n.promise;
    }
    function C(t) {
        return y(t, function(t) {
            return t = B(t, p), y(E(B(t, function(t) {
                return y(t, D, D);
            })), function() {
                return t;
            });
        });
    }
    var Q = !1;
    try {
        throw new Error();
    } catch (t) {
        Q = !!t.stack;
    }
    var _, N, P = s(), D = function() {}, A = function() {
        function n() {
            for (var t, n; r.next; ) t = (r = r.next).task, r.task = void 0, (n = r.domain) && (r.domain = void 0, 
            n.enter()), e(t, n);
            for (;f.length; ) e(t = f.pop());
            i = !1;
        }
        function e(t, e) {
            try {
                t();
            } catch (t) {
                if (c) throw e && e.exit(), setTimeout(n, 0), e && e.enter(), t;
                setTimeout(function() {
                    throw t;
                }, 0);
            }
            e && e.exit();
        }
        var r = {
            task: void 0,
            next: null
        }, o = r, i = !1, u = void 0, c = !1, f = [];
        if (A = function(t) {
            o = o.next = {
                task: t,
                domain: c && process.domain,
                next: null
            }, i || (i = !0, u());
        }, "object" === ("undefined" == typeof process ? "undefined" : t(process)) && "[object process]" === process.toString() && process.nextTick) c = !0, 
        u = function() {
            process.nextTick(n);
        }; else if ("function" == typeof setImmediate) u = "undefined" != typeof window ? setImmediate.bind(window, n) : function() {
            setImmediate(n);
        }; else if ("undefined" != typeof MessageChannel) {
            var s = new MessageChannel();
            s.port1.onmessage = function() {
                u = p, s.port1.onmessage = n, n();
            };
            var p = function() {
                s.port2.postMessage(0);
            };
            u = function() {
                setTimeout(n, 0), p();
            };
        } else u = function() {
            setTimeout(n, 0);
        };
        return A.runAfter = function(t) {
            f.push(t), i || (i = !0, u());
        }, A;
    }(), I = Function.call, U = n(Array.prototype.slice), F = n(Array.prototype.reduce || function(t, n) {
        var e = 0, r = this.length;
        if (1 === arguments.length) for (;;) {
            if (e in this) {
                n = this[e++];
                break;
            }
            if (++e >= r) throw new TypeError();
        }
        for (;e < r; e++) e in this && (n = t(n, this[e], e));
        return n;
    }), M = n(Array.prototype.indexOf || function(t) {
        for (var n = 0; n < this.length; n++) if (this[n] === t) return n;
        return -1;
    }), B = n(Array.prototype.map || function(t, n) {
        var e = this, r = [];
        return F(e, function(o, i, u) {
            r.push(t.call(n, i, u, e));
        }, void 0), r;
    }), $ = Object.create || function(t) {
        function n() {}
        return n.prototype = t, new n();
    }, V = Object.defineProperty || function(t, n, e) {
        return t[n] = e.value, t;
    }, G = n(Object.prototype.hasOwnProperty), H = Object.keys || function(t) {
        var n = [];
        for (var e in t) G(t, e) && n.push(e);
        return n;
    }, L = n(Object.prototype.toString);
    N = "undefined" != typeof ReturnValue ? ReturnValue : function(t) {
        this.value = t;
    };
    var q = "From previous event:";
    p.resolve = p, p.nextTick = A, p.longStackSupport = !1;
    var z = 1;
    "object" === ("undefined" == typeof process ? "undefined" : t(process)) && process && process.env && process.env.Q_DEBUG && (p.longStackSupport = !0), 
    p.defer = a, a.prototype.makeNodeResolver = function() {
        var t = this;
        return function(n, e) {
            n ? t.reject(n) : arguments.length > 2 ? t.resolve(U(arguments, 1)) : t.resolve(e);
        };
    }, p.Promise = l, p.promise = l, l.race = d, l.all = E, l.reject = g, l.resolve = p, 
    p.passByCopy = function(t) {
        return t;
    }, h.prototype.passByCopy = function() {
        return this;
    }, p.join = function(t, n) {
        return p(t).join(n);
    }, h.prototype.join = function(t) {
        return p([ this, t ]).spread(function(t, n) {
            if (t === n) return t;
            throw new Error("Q can't join: not the same: " + t + " " + n);
        });
    }, p.race = d, h.prototype.race = function() {
        return this.then(p.race);
    }, p.makePromise = h, h.prototype.toString = function() {
        return "[object Promise]";
    }, h.prototype.then = function(t, n, e) {
        function r(n) {
            try {
                return "function" == typeof t ? t(n) : n;
            } catch (t) {
                return g(t);
            }
        }
        function i(t) {
            if ("function" == typeof n) {
                o(t, c);
                try {
                    return n(t);
                } catch (t) {
                    return g(t);
                }
            }
            return g(t);
        }
        function u(t) {
            return "function" == typeof e ? e(t) : t;
        }
        var c = this, f = a(), s = !1;
        return p.nextTick(function() {
            c.promiseDispatch(function(t) {
                s || (s = !0, f.resolve(r(t)));
            }, "when", [ function(t) {
                s || (s = !0, f.resolve(i(t)));
            } ]);
        }), c.promiseDispatch(void 0, "when", [ void 0, function(t) {
            var n, e = !1;
            try {
                n = u(t);
            } catch (t) {
                if (e = !0, !p.onerror) throw t;
                p.onerror(t);
            }
            e || f.notify(n);
        } ]), f.promise;
    }, p.tap = function(t, n) {
        return p(t).tap(n);
    }, h.prototype.tap = function(t) {
        return t = p(t), this.then(function(n) {
            return t.fcall(n).thenResolve(n);
        });
    }, p.when = y, h.prototype.thenResolve = function(t) {
        return this.then(function() {
            return t;
        });
    }, p.thenResolve = function(t, n) {
        return p(t).thenResolve(n);
    }, h.prototype.thenReject = function(t) {
        return this.then(function() {
            throw t;
        });
    }, p.thenReject = function(t, n) {
        return p(t).thenReject(n);
    }, p.nearer = v, p.isPromise = m, p.isPromiseAlike = k, p.isPending = function(t) {
        return m(t) && "pending" === t.inspect().state;
    }, h.prototype.isPending = function() {
        return "pending" === this.inspect().state;
    }, p.isFulfilled = function(t) {
        return !m(t) || "fulfilled" === t.inspect().state;
    }, h.prototype.isFulfilled = function() {
        return "fulfilled" === this.inspect().state;
    }, p.isRejected = function(t) {
        return m(t) && "rejected" === t.inspect().state;
    }, h.prototype.isRejected = function() {
        return "rejected" === this.inspect().state;
    };
    var J = [], K = [], W = [], X = !0;
    p.resetUnhandledRejections = w, p.getUnhandledReasons = function() {
        return J.slice();
    }, p.stopUnhandledRejectionTracking = function() {
        w(), X = !1;
    }, w(), p.reject = g, p.fulfill = x, p.master = function(t) {
        return h({
            isDef: function() {}
        }, function(n, e) {
            return S(t, n, e);
        }, function() {
            return p(t).inspect();
        });
    }, p.spread = R, h.prototype.spread = function(t, n) {
        return this.all().then(function(n) {
            return t.apply(void 0, n);
        }, n);
    }, p.async = function(t) {
        return function() {
            function n(t, n) {
                var u;
                if ("undefined" == typeof StopIteration) {
                    try {
                        u = e[t](n);
                    } catch (t) {
                        return g(t);
                    }
                    return u.done ? p(u.value) : y(u.value, o, i);
                }
                try {
                    u = e[t](n);
                } catch (t) {
                    return r(t) ? p(t.value) : g(t);
                }
                return y(u, o, i);
            }
            var e = t.apply(this, arguments), o = n.bind(n, "next"), i = n.bind(n, "throw");
            return o();
        };
    }, p.spawn = function(t) {
        p.done(p.async(t)());
    }, p.return = function(t) {
        throw new N(t);
    }, p.promised = function(t) {
        return function() {
            return R([ this, E(arguments) ], function(n, e) {
                return t.apply(n, e);
            });
        };
    }, p.dispatch = S, h.prototype.dispatch = function(t, n) {
        var e = this, r = a();
        return p.nextTick(function() {
            e.promiseDispatch(r.resolve, t, n);
        }), r.promise;
    }, p.get = function(t, n) {
        return p(t).dispatch("get", [ n ]);
    }, h.prototype.get = function(t) {
        return this.dispatch("get", [ t ]);
    }, p.set = function(t, n, e) {
        return p(t).dispatch("set", [ n, e ]);
    }, h.prototype.set = function(t, n) {
        return this.dispatch("set", [ t, n ]);
    }, p.del = p.delete = function(t, n) {
        return p(t).dispatch("delete", [ n ]);
    }, h.prototype.del = h.prototype.delete = function(t) {
        return this.dispatch("delete", [ t ]);
    }, p.mapply = p.post = function(t, n, e) {
        return p(t).dispatch("post", [ n, e ]);
    }, h.prototype.mapply = h.prototype.post = function(t, n) {
        return this.dispatch("post", [ t, n ]);
    }, p.send = p.mcall = p.invoke = function(t, n) {
        return p(t).dispatch("post", [ n, U(arguments, 2) ]);
    }, h.prototype.send = h.prototype.mcall = h.prototype.invoke = function(t) {
        return this.dispatch("post", [ t, U(arguments, 1) ]);
    }, p.fapply = function(t, n) {
        return p(t).dispatch("apply", [ void 0, n ]);
    }, h.prototype.fapply = function(t) {
        return this.dispatch("apply", [ void 0, t ]);
    }, p.try = p.fcall = function(t) {
        return p(t).dispatch("apply", [ void 0, U(arguments, 1) ]);
    }, h.prototype.fcall = function() {
        return this.dispatch("apply", [ void 0, U(arguments) ]);
    }, p.fbind = function(t) {
        var n = p(t), e = U(arguments, 1);
        return function() {
            return n.dispatch("apply", [ this, e.concat(U(arguments)) ]);
        };
    }, h.prototype.fbind = function() {
        var t = this, n = U(arguments);
        return function() {
            return t.dispatch("apply", [ this, n.concat(U(arguments)) ]);
        };
    }, p.keys = function(t) {
        return p(t).dispatch("keys", []);
    }, h.prototype.keys = function() {
        return this.dispatch("keys", []);
    }, p.all = E, h.prototype.all = function() {
        return E(this);
    }, p.any = O, h.prototype.any = function() {
        return O(this);
    }, p.allResolved = function(t, n, e) {
        return function() {
            return "undefined" != typeof console && "function" == typeof console.warn && console.warn(n + " is deprecated, use " + e + " instead.", new Error("").stack), 
            t.apply(t, arguments);
        };
    }(C, "allResolved", "allSettled"), h.prototype.allResolved = function() {
        return C(this);
    }, p.allSettled = function(t) {
        return p(t).allSettled();
    }, h.prototype.allSettled = function() {
        return this.then(function(t) {
            return E(B(t, function(t) {
                function n() {
                    return t.inspect();
                }
                return (t = p(t)).then(n, n);
            }));
        });
    }, p.fail = p.catch = function(t, n) {
        return p(t).then(void 0, n);
    }, h.prototype.fail = h.prototype.catch = function(t) {
        return this.then(void 0, t);
    }, p.progress = function(t, n) {
        return p(t).then(void 0, void 0, n);
    }, h.prototype.progress = function(t) {
        return this.then(void 0, void 0, t);
    }, p.fin = p.finally = function(t, n) {
        return p(t).finally(n);
    }, h.prototype.fin = h.prototype.finally = function(t) {
        if (!t || "function" != typeof t.apply) throw new Error("Q can't apply finally callback");
        return t = p(t), this.then(function(n) {
            return t.fcall().then(function() {
                return n;
            });
        }, function(n) {
            return t.fcall().then(function() {
                throw n;
            });
        });
    }, p.done = function(t, n, e, r) {
        return p(t).done(n, e, r);
    }, h.prototype.done = function(n, e, r) {
        var i = function(t) {
            p.nextTick(function() {
                if (o(t, u), !p.onerror) throw t;
                p.onerror(t);
            });
        }, u = n || e || r ? this.then(n, e, r) : this;
        "object" === ("undefined" == typeof process ? "undefined" : t(process)) && process && process.domain && (i = process.domain.bind(i)), 
        u.then(void 0, i);
    }, p.timeout = function(t, n, e) {
        return p(t).timeout(n, e);
    }, h.prototype.timeout = function(t, n) {
        var e = a(), r = setTimeout(function() {
            n && "string" != typeof n || ((n = new Error(n || "Timed out after " + t + " ms")).code = "ETIMEDOUT"), 
            e.reject(n);
        }, t);
        return this.then(function(t) {
            clearTimeout(r), e.resolve(t);
        }, function(t) {
            clearTimeout(r), e.reject(t);
        }, e.notify), e.promise;
    }, p.delay = function(t, n) {
        return void 0 === n && (n = t, t = void 0), p(t).delay(n);
    }, h.prototype.delay = function(t) {
        return this.then(function(n) {
            var e = a();
            return setTimeout(function() {
                e.resolve(n);
            }, t), e.promise;
        });
    }, p.nfapply = function(t, n) {
        return p(t).nfapply(n);
    }, h.prototype.nfapply = function(t) {
        var n = a(), e = U(t);
        return e.push(n.makeNodeResolver()), this.fapply(e).fail(n.reject), n.promise;
    }, p.nfcall = function(t) {
        var n = U(arguments, 1);
        return p(t).nfapply(n);
    }, h.prototype.nfcall = function() {
        var t = U(arguments), n = a();
        return t.push(n.makeNodeResolver()), this.fapply(t).fail(n.reject), n.promise;
    }, p.nfbind = p.denodeify = function(t) {
        if (void 0 === t) throw new Error("Q can't wrap an undefined function");
        var n = U(arguments, 1);
        return function() {
            var e = n.concat(U(arguments)), r = a();
            return e.push(r.makeNodeResolver()), p(t).fapply(e).fail(r.reject), r.promise;
        };
    }, h.prototype.nfbind = h.prototype.denodeify = function() {
        var t = U(arguments);
        return t.unshift(this), p.denodeify.apply(void 0, t);
    }, p.nbind = function(t, n) {
        var e = U(arguments, 2);
        return function() {
            var r = e.concat(U(arguments)), o = a();
            return r.push(o.makeNodeResolver()), p(function() {
                return t.apply(n, arguments);
            }).fapply(r).fail(o.reject), o.promise;
        };
    }, h.prototype.nbind = function() {
        var t = U(arguments, 0);
        return t.unshift(this), p.nbind.apply(void 0, t);
    }, p.nmapply = p.npost = function(t, n, e) {
        return p(t).npost(n, e);
    }, h.prototype.nmapply = h.prototype.npost = function(t, n) {
        var e = U(n || []), r = a();
        return e.push(r.makeNodeResolver()), this.dispatch("post", [ t, e ]).fail(r.reject), 
        r.promise;
    }, p.nsend = p.nmcall = p.ninvoke = function(t, n) {
        var e = U(arguments, 2), r = a();
        return e.push(r.makeNodeResolver()), p(t).dispatch("post", [ n, e ]).fail(r.reject), 
        r.promise;
    }, h.prototype.nsend = h.prototype.nmcall = h.prototype.ninvoke = function(t) {
        var n = U(arguments, 1), e = a();
        return n.push(e.makeNodeResolver()), this.dispatch("post", [ t, n ]).fail(e.reject), 
        e.promise;
    }, p.nodeify = function(t, n) {
        return p(t).nodeify(n);
    }, h.prototype.nodeify = function(t) {
        if (!t) return this;
        this.then(function(n) {
            p.nextTick(function() {
                t(null, n);
            });
        }, function(n) {
            p.nextTick(function() {
                t(n);
            });
        });
    }, p.noConflict = function() {
        throw new Error("Q.noConflict only works when Q is used as a global");
    };
    var Y = s();
    return p;
});